<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="js/vue.js"></script>
    <title>Document</title>
    <style>
        #app ul {
            list-style: none;
            display: flex;
            width: 200px;
            height: 30px;
            line-height:30px;
        }
        #app ul li{
            flex: 1;
            border: 1px solid black;
            text-align:center;
        }
        .active{
            background-color:blue;
        }
    </style>
</head>
<body>
    <div id="app">
        <ul>
            <li @click="changeColor(index)" v-for="item,index in data" :class="current === index  ? 'active' : '' "><a href="#">{{ item }}</a></li>
        </ul>
    </div>
    <script>
        var vm = new Vue({
            el:"#app",
            data:{
                data:["首页","商品","详情"],
                current: 0
            },
            methods:{
                changeColor(index){
                    this.current = index
                }
            }
        });
    </script>
</body>
</html>